package com.itlong.cloud.commons.service.impl;

import com.itlong.cloud.commons.dao.IUpdateUserAndRoomForbiddenStatusDao;
import com.itlong.cloud.commons.service.IUpdateUserAndRoomForbiddenStatusService;
import com.itlong.cloud.rabbitmq.config.MessageSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <desc>
 *      更新用户和房间欠费状态处理类.
 * </desc>
 *
 * @createDate 2019/1/22
 */
@Service
public class UpdateUserAndRoomForbiddenStatusServiceImpl implements IUpdateUserAndRoomForbiddenStatusService{

    @Autowired
    IUpdateUserAndRoomForbiddenStatusDao iUpdateUserAndRoomForbiddenStatusDao;

    @Autowired
    private MessageSender messageSender;
    /**
     * <desc>
     *      更新用户和房间欠费状态
     * <desc/>
     *
     * @param   feeId 账单ID
     * @author Juguang.S
     * @createDate 2019/01/22
     */
    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public void updateUserAndRoomForbiddenStatus(String feeId) throws Exception {
//        List<AppUserAndRoomInfoVO> list = iUpdateUserAndRoomForbiddenStatusDao.getForbiddenInfo(feeId);
//        List<String> userIdList = new ArrayList<>();
//        List<String> roomIdList = new ArrayList<>();
//        JSONArray pushRoom = new JSONArray();
//        JSONObject dataJs = new JSONObject();
//        for(AppUserAndRoomInfoVO roomInfoVO : list){
//            userIdList.add(roomInfoVO.getUserId());
//            roomIdList.add(roomInfoVO.getRoomId());
//            JSONObject json = new JSONObject();
//            json.put("unitId", roomInfoVO.getUnitId());
//            json.put("buildId", roomInfoVO.getBuildId());
//            json.put("roomId", roomInfoVO.getRoomId());
//            pushRoom.add(json);
//        }
//        //修改app_user_project欠费状态
//        iUpdateUserAndRoomForbiddenStatusDao.updateUserStatus(userIdList);
//        //修改room_info欠费状态
//        iUpdateUserAndRoomForbiddenStatusDao.updateRoomStatus(roomIdList);
//
//        //向云对讲推送房间信息变更指令
//        List<DeviceBusinessChangeLogPO> changeLogPOS = new ArrayList<>();
//        DeviceBusinessChangeLogPO deviceBusinessChangeLogPO =
//                new DeviceBusinessChangeLogPO(SmartCommunityEnum.PUSH_ROOM, pushRoom.toJSONString(), list.get(0).getProjectId());
//        changeLogPOS.add(deviceBusinessChangeLogPO);
//        if (!changeLogPOS.isEmpty()) {
//            dataJs = new JSONObject();
//            dataJs.put("data",changeLogPOS);
//
//            messageSender.send(RabbitMQConstant.RABBITMQ_HANDLE_SMART_COMMUNITY_ORDERS_QUEUE,
//                    JsonUtil.toJSON(dataJs), RabbitMQConstant.RABBITMQ_SMART_COMMUNITY_ORDERS_EXCHANGE,
//                    RabbitMQConstant.RABBITMQ_SMART_COMMUNITY_ORDERS_ROUTING_KEY);
//        }

    }
}